$.ping = function() 
{
    var ping, requestTime, responseTime ;
    //允许等待的超时时间毫秒
    var allowwait = 1000;
    $.ajax({
//        url: "http://www.baidu.com"+'/'+ (new Date()).getTime() + '.html',  
        url: "http://s5.cnzz.com",  
        type: 'GET',
        dataType: "json", //跨域采用jsonp方式 
//        dataType: "html", //跨域采用jsonp方式 
//        processData: false,
        timeout: 1000,
        beforeSend : function() 
        {
        	requestTime = new Date().getTime();
        	console.log("开始ping--->baidu:"+requestTime);
        },
        complete : function(xhr) 
        {
            responseTime = new Date().getTime();
            ping = Math.abs(requestTime - responseTime);
            console.log("所需时间:"+ping);
            console.log(xhr.statusText);
            //访问百度1s之内认为具备访问外网能力
            if(ping <= allowwait){
            	var sitId = window.sessionStorage.getItem("sitId");
            	if(sitId != 0 && sitId !='0' && sitId){
            		console.log("开始加载用户行为分析js");
            		var cnzz_protocol = (("https:" == document.location.protocol) ? "https://" : "http://");
            		var sitdocument = document.createElement('script');
            		sitdocument.type = 'text/javascript';
            		sitdocument.async = true;
            		sitdocument.src = cnzz_protocol + "s5.cnzz.com/z_stat.php?id="+sitId;
            		var script = document.getElementsByTagName('script')[document.getElementsByTagName('script').length-1]; 
            		script.parentNode.insertBefore(sitdocument, script);
            		
              		var sitwebdocument = document.createElement('script');
              		sitwebdocument.type = 'text/javascript';
              		sitwebdocument.async = true;
              		sitwebdocument.src = cnzz_protocol + "c.cnzz.com/core.php?web_id="+sitId+"&t=z";
            		var scriptw = document.getElementsByTagName('script')[document.getElementsByTagName('script').length-1]; 
            		scriptw.parentNode.insertBefore(sitwebdocument, scriptw);
               	}
            }
        }
    });
};$($.ping())